﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CrusadeGmTool.ComponentModel;
using System.Diagnostics;
using System.ComponentModel;

namespace CrusadeGmTool.Models
{
    [DefaultPropertyAttribute("OnlineCount")]
    public class ServerInfo:NotifierBase
    {
        private int _activeAccountsCount;
        private int _bannedAccountsCount;
        private int _firewalledIpCount;
        private int _onlineCount;
        private int _mobileCount;
        private int _scriptedMobilesCount;
        private int _itemsCount;
        private int _scriptedItemsCount;
        private TimeSpan _uptime;
        private uint _memoryUsage;
        private uint _totalMemory;
        private string _dotNetVersion;
        private string _osVersion;
        private bool _initialized;
        
        #region properties
        [BrowsableAttribute(false)]
        public uint TotalMemory
        {
            get { return _totalMemory; }
            set { _totalMemory = value; }
        }
        [BrowsableAttribute(false)]
        public bool Initialized
        {
            get { return _initialized; }
            set
            {
                if (_initialized != value)
                {
                    _initialized = value;
                    RaisePropertyChanged("Initialized", "Visibility");
                }
            }
        }
        [CategoryAttribute("server Hardware"),
DescriptionAttribute("Os du Serveur"),
DisplayNameAttribute("OS")]
        public string OSVersion
        {
            get { return _osVersion; }
            set
            {
                if (_osVersion != value)
                {
                    _osVersion = value;
                    RaisePropertyChanged("OSVersion");
                }
            }
        }
        [CategoryAttribute("server Hardware"),
DescriptionAttribute("Version de .net utilisée par le serveur"),
DisplayNameAttribute("Version de .net")]
        public string DotNetVersion
        {
            get { return _dotNetVersion; }
            set
            {
                if (_dotNetVersion != value)
                {
                    _dotNetVersion = value;
                    RaisePropertyChanged("DotNetVersion");
                }
            }
        }

        [CategoryAttribute("server Hardware"),
    DescriptionAttribute("Memoire RAM utilisée par RunUO"),
        DisplayNameAttribute("Memoire Utilisée")]

        public string MemoryUsageToString
        {
            get
            {
                UInt32 Mb = (MemoryUsage) / 1000000;
                return String.Format("{0} Mb",Mb);
            }
            set
            {
                //dummy set for property grid
            }
        }
    [BrowsableAttribute(false)]
        public uint MemoryUsage
        {
            get { return _memoryUsage; }
            set
            {
                if (_memoryUsage != value)
                {
                    _memoryUsage = value;
                    RaisePropertyChanged("MemoryUsage");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("temps depuis lequel le serveur tourne sans interruption"),
DisplayNameAttribute("Uptime")]
        public TimeSpan Uptime
        {
            get { return _uptime; }
            set
            {
                if (_uptime != value)
                {
                    _uptime = value;
                    RaisePropertyChanged("Uptime");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre d'objets scriptés sur le serveur"),
DisplayNameAttribute("Nombre d'objets scriptés")]
        public int ScriptedItemsCount
        {
            get { return _scriptedItemsCount; }
            set
            {
                if (_scriptedItemsCount != value)
                {
                    _scriptedItemsCount = value;
                    RaisePropertyChanged("ScriptedItemsCount");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre d'objets sur le serveur"),
DisplayNameAttribute("Nombre d'objets")]
        public int ItemsCount
        {
            get { return _itemsCount; }
            set
            {
                if (_itemsCount != value)
                {
                    _itemsCount = value;
                    RaisePropertyChanged("ItemsCount");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre de scripts de mob sur le serveur"),
DisplayNameAttribute("Nombre de scripts de mob")]
        public int ScriptMobilesCount
        {
            get { return _scriptedMobilesCount; }
            set
            {
                if (_scriptedMobilesCount != value)
                {
                    _scriptedMobilesCount = value;
                    RaisePropertyChanged("ScriptMobilesCount");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre de mobs sur le serveur"),
DisplayNameAttribute("Nombre de mobs")]
        public int MobileCount
        {
            get { return _mobileCount; }
            set
            {
                if (_mobileCount != value)
                {
                    _mobileCount = value;
                    RaisePropertyChanged("MobileCount");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre de comptes actuellement online"),
DisplayNameAttribute("Comptes online")]
        public int OnlineCount
        {
            get { return _onlineCount; }
            set
            {
                if (_onlineCount != value)
                {
                    _onlineCount = value;
                    RaisePropertyChanged("OnlineCount");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre d'adresses IP bannies"),
DisplayNameAttribute("IP bannies")]
        public int FirewalledIpCount
        {
            get { return _firewalledIpCount; }
            set
            {
                if (_firewalledIpCount != value)
                {
                    _firewalledIpCount = value;
                    RaisePropertyChanged("FirewalledIpCount");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre de comptes bannis"),
DisplayNameAttribute("comptes bannis")]
        public int BannedAccountsCount
        {
            get { return _bannedAccountsCount; }
            set
            {
                if (_bannedAccountsCount != value)
                {
                    _bannedAccountsCount = value;
                    RaisePropertyChanged("BannedAccountsCount");
                }
            }
        }
        [CategoryAttribute("server infos"),
DescriptionAttribute("Nombre de comptes actifs"),
DisplayNameAttribute("comptes actifs")]
        public int ActiveAccountsCount
        {
            get { return _activeAccountsCount; }
            set
            {
                if (_activeAccountsCount != value)
                {
                    _activeAccountsCount = value;
                    RaisePropertyChanged("ActiveAccountsCount");
                }
            }
        }
        #endregion
    }
}
